package com.stb.shared.util;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;

public final class ListFactory 
{
	private ListFactory() {
	}
	
	public static <T> List<T> create(T... values) {
		return Collections.unmodifiableList(Arrays.asList(values));
	}

	public static <T> List<T> create(List<T> existing, T... values) {
		List<T> newList = new ArrayList<T>(existing);
		newList.addAll(Arrays.asList(values));
		return Collections.unmodifiableList(newList);
	}

	public static <T> List<T> create(Set<T> existing) {
		List<T> newList = new ArrayList<T>(existing);
		return Collections.unmodifiableList(newList);
	}
	
	public static <T> List<T> createReverse(T... values) {
		List<T> list = Arrays.asList(values);
		Collections.reverse(list);
		return Collections.unmodifiableList(list);
	}
	
	public static List<String> createStringList(List<?> list) {
		List<String> result = new ArrayList<String>();
		for (Object item : list){
			result.add(item.toString());
		}
		return result;
	}
}
